/**
 * Author: ligj@mapbar.com
 * Create Time: 2017/12/15 15:15
 * Description: 拦截器配置
 */
let Interceptors = {
    request: function (config) {
        let token = window.localStorage.getItem('token') || null
        if (token) {
            config.headers['Token'] = token
        }
        return config
    },
    requestError: function (error) {
        return Promise.reject(error)
    },
    response: function (response) {
        if (!response.data.code) {
          response.data.code = response.data.status || response.data.resultCode
        }
        return response
    },
    responseError: function (error) {
        return Promise.reject(error)
    }
}

export default Interceptors
